package alg20241112;

public class Text {
    public int findMin1(int[] nums) {
        int n = nums.length;
        int left = 0, right = n - 1;
        while(left < right){
            int mid = left + (right - left) / 2;
            if(nums[mid] <= nums[n-1]){
                right = mid;
            }else{
                left = mid + 1;
            }
        }
        return nums[left];
    }
    public int findMin(int[] nums) {
        int n = nums.length;
        int left = 0, right = n - 1;
        if(nums[n-1] > nums[0])  return nums[0];
        while(left < right){
            int mid = left + (right - left) / 2;
            if(nums[mid] >= nums[0]){
                left = mid + 1;
            }else{
                right = mid;
            }
        }
        return nums[left];
    }
}
